package com.zmx.patientend.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.wang.adapters.adapter.BaseAdapterRvList;
import com.wang.adapters.base.BaseViewHolder;
import com.zmx.patientend.R;
import com.zmx.patientend.pojo.ArticleMessage;

import butterknife.BindView;
import butterknife.ButterKnife;

public class ArticleMessageAdapter extends BaseAdapterRvList<ArticleMessageAdapter.ViewHolder, ArticleMessage> {


    public ArticleMessageAdapter(Activity activity) {
        super(activity);
    }

    @Override
    protected void onBindVH(ViewHolder holder, int listPosition, ArticleMessage articleMessage) {

        if(listPosition == 0){

            holder.liLayout.setVisibility(View.VISIBLE);
            holder.layout.setVisibility(View.GONE);
            Glide.with(mActivity).load(articleMessage.getCover()).into(holder.image);
            holder.title.setText(articleMessage.getTitle());

        }else{

            holder.liLayout.setVisibility(View.GONE);
            holder.layout.setVisibility(View.VISIBLE);
            Glide.with(mActivity).load(articleMessage.getCover()).into(holder.members_head);
            holder.members_name.setText(articleMessage.getTitle());
            holder.time_text.setText(articleMessage.getPubtime());

        }


    }

    @NonNull
    @Override
    protected ViewHolder onCreateVH(ViewGroup parent, LayoutInflater inflater) {

        ArticleMessageAdapter.ViewHolder holder = new ArticleMessageAdapter.ViewHolder(inflater.inflate(R.layout.adapter_article, parent, false));
        return holder;

    }

    static class ViewHolder extends BaseViewHolder {

        @BindView(R.id.members_head)
        ImageView members_head;
        @BindView(R.id.members_name)
        TextView members_name;
        @BindView(R.id.time_text)
        TextView time_text;


        @BindView(R.id.image)
        ImageView image;
        @BindView(R.id.title)
        TextView title;
        @BindView(R.id.liLayout)
        LinearLayout liLayout;

        @BindView(R.id.layout)
        RelativeLayout layout;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

    }


}
